package com.kedacom.ctsp.authority.vo;


import com.kedacom.ctsp.authority.entity.Department;
import com.kedacom.ctsp.authority.util.AuthorityTreeUtil;
import com.kedacom.ctsp.lang.mapper.BeanMapperException;
import com.kedacom.ctsp.lang.mapper.CollComponentType;
import com.kedacom.ctsp.web.vo.AbstractTreeSortSupportVO;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.util.List;

/**
 * 部门
 *
 * @author
 */
@Data
@ApiModel
public class SimpleDepartmentVO extends AbstractTreeSortSupportVO<Department, DepartmentVO, String> implements DepartmentVO {

    /**
     * 主键id ，自增长
     */
    private String id;

    /**
     * 所在地区id
     */
    private String district;
    /**
     * 名称
     */
    private String name;
    /**
     * 全称
     */
    private String fullName;
    /**
     * 部门编码
     */
    private String code;
    /**
     * 描述
     */
    private String description;

    /**
     * 角色
     */
    @CollComponentType(RoleVO.class)
    private List<RoleVO> roles;

    @Override
    public Department convertTo(Department department) throws BeanMapperException {
        super.convertTo(department);
        AuthorityTreeUtil.addParent(department, this);
        return department;
    }

    /**
     * 扩展字段
     */
    private String extendedField;
    /**
     * 单位级别
     */
    private String grade;
    /**
     * 单位类型
     */
    private String type;
    @CollComponentType(DepartmentVO.class)
    private List<DepartmentVO> children;
}